<template>
  <div class="modal-from">
    <a-modal
      :bodyStyle="{ padding: '0 24px' }"
      title="新增产品物料"
      :width="1000"
      style="top: 50px"
      :visible="visible"
      :confirmLoading="confirmLoading"
      @ok="submit"
      @cancel="handleCancel"
    >
      <div class="table-page-search-wrapper">
        <a-form :form="form" layout="inline">
          <a-row :gutter="24" style="margin: 10px; padding: 10px">
            <!--上面-->
            <a-col>
              <a-row class="rowStyle" :gutter="24">
                <a-col :span="6">
                  <a-form-item label="产品编码">
                    <!-- <a-input placeholder="请输入"       v-decorator="[
        record.model, // input 的 name
        {
          initialValue: record.options.defaultValue, // 默认值
          rules: record.rules // 验证规则
        }
      ]"></a-input> -->
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="产品名称">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="打印名称">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="产品类别"> <a-input placeholder="请输入"></a-input> </a-form-item
                ></a-col>
              </a-row>
            </a-col>
            <a-col>
              <a-row :gutter="24" class="rowStyle">
                <a-col :span="6">
                  <a-form-item label="产品类型">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="剂型">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="是否赠送">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="保值期(天)"> <a-input placeholder="请输入"></a-input> </a-form-item
                ></a-col>
              </a-row>
            </a-col>
            <a-col>
              <a-row :gutter="24">
                <a-col :span="6">
                  <a-form-item label="是否折扣">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="出库方式">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="库存上限">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="库存下限"> <a-input placeholder="请输入"></a-input> </a-form-item
                ></a-col>
              </a-row>
            </a-col>
            <a-col>
              <a-row :gutter="24">
                <a-col :span="6">
                  <a-form-item label="是否禁用">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="批准文号">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="仓位">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="业绩科室"> <a-input placeholder="请输入"></a-input> </a-form-item
                ></a-col>
              </a-row>
            </a-col>
            <a-col>
              <a-row :gutter="24">
                <a-col :span="6">
                  <a-form-item label="注册文号">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="产地">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6">
                  <a-form-item label="生产厂家">
                    <a-input placeholder="请输入"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="6"></a-col>
              </a-row>
            </a-col>
            <a-col>
              <a-row :gutter="24">
                <a-col :span="12">
                  <a-form-item label="备注">
                    <a-textarea placeholder="请输入"></a-textarea>
                  </a-form-item>
                </a-col>

                <a-col :span="12">
                  <a-radio-group>
                    <a-radio label="核算成交">核算成交</a-radio>
                    <a-radio label="核算业绩">核算业绩</a-radio>
                    <a-radio label="是否销售">是否销售</a-radio>
                  </a-radio-group>
                </a-col>
              </a-row>
            </a-col>
            <a-col :span="24">
              <div><span>单位定义</span><a-button type="primary">新增</a-button></div>
            </a-col>
            <a-col :span="24">
              <super-table
                ls_props_columns="projectManage_table"
                :scroll="{ x: 1000 }"
                ref="table"
                :pageSize="10"
                :columns="columns"
                :data="loadData"
                :rowKey="(record) => record.id"
              >
                <template slot="action" slot-scope="text, record">
                  <div class="g-flex g-y-center">
                    <a-button type="link" @click="editProject(record)">编辑</a-button>
                  </div>
                </template>
              </super-table>
              <!-- <super-table :data="[]"></super-table> -->
            </a-col>
            <!-- <a-col :span="16" style="border-right: 1px solid #E8E8E8;padding-top: 16px;padding-bottom: 16px;">
              <a-row :gutter="16">
                <a-col :span="12">
                  <a-form-item
                    label="产品编号"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['code',{rules: [{ required: false, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
                <a-col :span="12">
                  <a-form-item
                    label="产品名称"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['useTimes',{rules: [{ required: true, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="16">
                <a-col :span="12">
                  <a-form-item
                    label="打印名称"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['name',{rules: [{ required: true, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
                <a-col :span="12">
                  <a-form-item
                    label="项目单位"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['itemUnit',{rules: [{ required: false, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="16">
                <a-col :span="12">
                  <a-form-item
                    label="产品类别"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-select allow-clear style="width: 100%" v-decorator="['fylb', {rules: [{ required: true, message: '请选择费用类别！' }]}]" placeholder="请选择" >
                      <a-select-option v-for="(item,index) in []" :key="index" :value="item.id" >{{ item.name }}</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <a-col :span="12">
                  <a-form-item
                    label="项目售价"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['price',{rules: [{ required: true, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="16">
                <a-col :span="12">
                  <a-form-item
                    label="产品类型"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-select allow-clear style="width: 100%" v-decorator="['sslb', {rules: [{ required: true, message: '请选择所属类别！' }]}]" placeholder="请选择" >
                      <a-select-option v-for="(item,index) in []" :key="index" :value="item.id" >{{ item.name }}</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <a-col :span="12">
                  <a-form-item
                    label="手术名称"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['operateName',{rules: [{ required:false, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="16">
                <a-col :span="12">
                  <a-form-item
                    label="剂型"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['pyCode',{rules: [{ required: false, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
                <a-col :span="12">
                  <a-form-item
                    label="医生分值"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['doctorScore',{rules: [{ required: false, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="16">
                <a-col :span="12">
                  <a-form-item
                    label="是否赠送"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['printName',{rules: [{ required: true, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
                <a-col :span="12">
                  <a-form-item
                    label="护士分值"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-input
                      style="width: 100%"
                      placeholder="请输入"
                      v-decorator="['nurseScore',{rules: [{ required: false, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="16">
                <a-col :span="16">
                  <a-row :gutter="12">
                    <a-col :span="12">
                      <a-form-item
                        label="保质期（天）"
                        :wrapperCol="wrapperCol"
                        has-feedback
                        style="padding: 0"
                      >
                        <a-input
                          placeholder="0"
                          v-decorator="['minPrice',{rules: [{ required: true, message: '请输入！' }]}]"/>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12">
                      <a-form-item
                        label="最高价"
                        :wrapperCol="wrapperCol"
                        has-feedback
                      >
                        <a-input
                          style="width: 100%"
                          placeholder="0"
                          v-decorator="['maxPrice',{rules: [{ required: true, message: '请输入！' }]}]"/>
                      </a-form-item>
                    </a-col>
                  </a-row>
                </a-col>
              </a-row>
              <a-row :gutter="16">
                <a-col :span="24">
                  <a-form-item
                    label="是否折扣"
                    :wrapperCol="wrapperCol"
                    has-feedback
                  >
                    <a-textarea
                      :rows="2"
                      style="width: 548px;"
                      placeholder="请输入"
                      v-decorator="['modifier',{rules: [{ required: true, message: '请输入！' }]}]"/>
                  </a-form-item>
                </a-col>
              </a-row>
            </a-col>
 
            <a-col :span="8" style="padding:16px 20px;">
              <a-form-item
                label="执行科室"
                :wrapperCol="wrapperCol"
                has-feedback
              >
                <a-select allow-clear style="width: 100%" v-decorator="['zxks', {rules: [{ required: true, message: '请选择执行科室！' }]}]" placeholder="请选择" >
                  <a-select-option v-for="(item,index) in []" :key="index" :value="item.id" >{{ item.name }}</a-select-option>
                </a-select>
              </a-form-item>
              <a-form-item
                label="业绩科室"
                :wrapperCol="wrapperCol"
                has-feedback
              >
                <a-select allow-clear style="width: 100%" v-decorator="['yjke', {rules: [{ required: true, message: '请选择业绩科室！' }]}]" placeholder="请选择" >
                  <a-select-option v-for="(item,index) in []" :key="index" :value="item.id" >{{ item.name }}</a-select-option>
                </a-select>
              </a-form-item>
              <a-form-item
                label="二级业绩科室"
                :wrapperCol="wrapperCol"
                has-feedback
              >
                <a-select allow-clear style="width: 100%" v-decorator="['ejyjks', {rules: [{ required: true, message: '请选择二级业绩科室！' }]}]" placeholder="请选择" >
                  <a-select-option v-for="(item,index) in []" :key="index" :value="item.id" >{{ item.name }}</a-select-option>
                </a-select>
              </a-form-item>
              <a-form-item>
                <a-checkbox-group v-decorator="['group']">
                  <a-row :gutter="[0,12]">
                    <a-col :span="24">
                      <a-checkbox value="1">是否禁用</a-checkbox>
                    </a-col>
                    <a-col :span="24">
                      <a-checkbox value="2">是否允许使用增值金</a-checkbox>
                    </a-col>
                    <a-col :span="24">
                      <a-checkbox value="3">是否成交</a-checkbox>
                    </a-col>
                    <a-col :span="24">
                      <a-checkbox value="4">是否核算业绩</a-checkbox>
                    </a-col>
                    <a-col :span="24">
                      <a-checkbox value="5">是否需要执行</a-checkbox>
                    </a-col>
                  </a-row>
                </a-checkbox-group>
              </a-form-item>
            </a-col> -->
          </a-row>
        </a-form>
      </div>
    </a-modal>
  </div>
</template>

<script>
import { getItemDetailById } from '@/api/modular/main/customer/customerScene'
import { SuperTable } from '@/components'
import areaObj from '@/assets/flowable/js/areaData'
import infoSourceObj from '@/assets/flowable/js/infoSource'

export default {
  props: {
    modal_type: {
      type: String,
      default: 'add',
    },
    row_record: {
      type: Object,
      default: () => {},
    },
  },

  components: {
    SuperTable,
  },
  data() {
    return {
      queryParam: {
        searchValue: '',
        pageNum: 1, //第几页
        pageSize: 10, //每页中显示数据的条数
        id: undefined,
      },
      pagination: {
        current: 1, //当前页
        pageSize: 20, //当前页数
        total: 0, //总条数
        showSizeChanger: true,
        showQuickJumper: true,
        pageSizeOptions: ['10', '20', '30'], //这里注意只能是字符串，不能是数字
        showTotal: (total) => `共有 ${total} 条数据`, //分页中显示总的数据
      },
      // 表头
      columns: [
        { title: '计量单位', dataIndex: 'code', width: 120, fixed: 'left' },
        { title: '单位进制', dataIndex: '1', width: 120 },
        { title: '是否基本单位', dataIndex: '2', width: 120 },
        { title: '规格', dataIndex: '3', width: 120 },
        { title: '单位单价', dataIndex: 'name', width: 120, scopedSlots: { customRender: 'name' }, ellipsis: true },
        // { title: '核算成交', dataIndex: 'isAchieve', width: 100 },
        // { title: '核算业绩', dataIndex: 'isDeal', width: 100 },
        // { title: '是否需要执行', dataIndex: 'isExecute', width: 100 },
        // { title: '禁用', dataIndex: 'isDisabled', width: 100 },
        // { title: '次数', dataIndex: 'useTimes', width: 80 },
        // { title: '项目单位', dataIndex: 'itemUnit', width: 100 },
        // { title: '项目售价', dataIndex: 'price', width: 100 },
        // { title: '最低价', dataIndex: 'minPrice', width: 100 },
        // { title: '最高价', dataIndex: 'maxPrice', width: 100 },
        // { title: '执行科室', dataIndex: 'achieveDept', width: 100 },
        // { title: '业绩科室', dataIndex: 'execDept', width: 100 },
        // { title: '二级业绩科室', dataIndex: 'twoDeptName', width: 100 },
        // { title: '项目说明', dataIndex: 'modifier', width: 100 },
        // {
        //   title: '打印名称',
        //   dataIndex: 'printName',
        //   width: 100,
        //   scopedSlots: { customRender: 'printName' },
        //   ellipsis: true,
        // },
        // {
        //   title: '手术名称',
        //   dataIndex: 'operateName',
        //   width: 100,
        //   scopedSlots: { customRender: 'operateName' },
        //   ellipsis: true,
        // },
        // { title: '费用类别', dataIndex: 'royaltyRate', width: 100 },
        // { title: '医生分值', dataIndex: 'doctorScore', width: 100 },
        // { title: '护士分值', dataIndex: 'nurseScore', width: 100 },
        // { title: '编辑时间', dataIndex: 'recordDate', width: 100 },
        { title: '操作', scopedSlots: { customRender: 'action' }, fixed: 'right', width: 100 },
      ],
      loadData: (parameter) => {
        return getItemDetailById(Object.assign(parameter, this.queryParam)).then((res) => {
          console.log('右边表格', res)
          return res
        })
      },
      value: [],
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 },
      },
      visible: false,
      confirmLoading: false,
      form: this.$form.createForm(this),
      customerTableLoading: false,
      pagination: {
        current: 1, //当前页
        pageSize: 10, //当前页数
        total: 0, //总条数
        showSizeChanger: true,
        showQuickJumper: true,
        pageSizeOptions: ['10', '20', '30'], //这里注意只能是字符串，不能是数字
        showTotal: (total) => `共有 ${total} 条数据`, //分页中显示总的数据
      },
      customerDataTable: [],
    }
  },
  methods: {
    // 初始化方法
    add() {
      this.visible = true
      this.$nextTick(() => {
        console.log('111', this.modal_type, this.row_record)
        if (this.modal_type == 'add') {
          this.form.resetFields()
          return
        }
        if (this.modal_type == 'edit') {
          const record = this.row_record
          this.form.setFieldsValue({
            code: record.code,
            name: record.name,
            printName: record.printName,
            itemUnit: record.itemUnit,
            pyCode: record.pyCode,
            maxPrice: record.maxPrice,
            minPrice: record.minPrice,
            doctorScore: record.doctorScore,
            modifier: record.modifier,
            nurseScore: record.nurseScore,
            operateName: record.operateName,
            price: record.price,
            twoDeptId: null,
            twoDeptName: null,
            useTimes: record.useTimes,
            group: [1, 2, 3, 4, 5],
          })
        }
      })
    },
    /**
     提交表单
     * */
    submit() {
      const {
        form: { validateFields },
      } = this
      validateFields((errors, values) => {
        this.confirmLoading = true
        if (errors) {
          console.log('表单检验未通过111', errors, values)
          this.confirmLoading = false
          return
        }
        if (this.customer_response) {
          values.customer.customerId = this.customer_response.customerId
        }
        console.log('表单检验通过222', values)
      })
    },
    /**
     分页动作监听
     * */
    handleTableChange(pagination) {
      this.pagination.current = pagination.current
      this.pagination.pageSize = pagination.pageSize
      this.queryParam.pageNum = pagination.current
      this.queryParam.pageSize = pagination.pageSize
      this.getList()
    },
    handleCancel() {
      this.form.resetFields()
      this.visible = false
    },
  },
}
</script>

<style lang="less" scoped>
/deep/ .ant-card-head-title {
  font-weight: bold;
}

/deep/ .ant-page-header-heading-title {
  font-weight: normal;
  font-size: 16px;
}

/deep/ .ant-card-body {
  padding: 24px 12px 0 !important;
}

/deep/ .ant-form-item-control-wrapper {
  width: 100%;
}
/deep/ .ant-form-item-control {
  width: 100%;
}
/deep/ .ant-row {
  margin: 10 15px;
}
</style>